<template>
  <div class="body_album">
    <!-- 头部 -->
    <HeadArea :name="name" />
    <!-- 中间 框架 -->
    <div class="call">
      <div class="swiper mySwiper">
        <div class="swiper-wrapper">
          <div
            @click="goPalyLists(album.id)"
            class="swiper-slide"
            v-for="(album, index) in newAlbum"
            :key="album.id"
            v-if="index < 10"
          >
            <a> <img :src="album.picUrl" alt="" /></a>
            <p class="nop">
              <a href="javascript:;">{{ album.name }}</a>
            </p>
            <p>
              <a href="javascript:;">{{ album.artist.name }}</a>
            </p>
          </div>
        </div>
        <div class="swiper-button-next"></div>
        <div class="swiper-button-prev"></div>
        <div class="swiper-pagination"></div>
      </div>
    </div>
  </div>
</template>

<script>
import Swiper from "swiper";
import { mapState } from "vuex";
export default {
  data() {
    return {
      name: "新碟上架",
    };
  },
  mounted() {
    this.$nextTick(() => {
      setTimeout(() => {
        new Swiper(".mySwiper", {
          slidesPerView: 5,
          spaceBetween: 30,
          slidesPerGroup: 5,
          loop: true,
          loopFillGroupWithBlank: true,

          navigation: {
            nextEl: ".swiper-button-next",
            prevEl: ".swiper-button-prev",
          },
        });
      }, 300);
    });
    this.$store.dispatch("getNewAlbum");
    
  },
  methods:{
      // 跳转到albumpage页面
    goPalyLists(id){
        // console.log(id)
        this.$router.push(`/albumpage?id=${id}`)
    }
  },
  computed: {
    ...mapState({
      newAlbum: (state) => {
        return state.Home.newAlbum;
      },
    }),
  },
};
</script>

<style lang="less" scoped>
.body_album {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;
}
.nop {
  white-space: nowrop;
  overflow: hidden;
  text-align: center;

}

// 中间
.call {
  position: relative;
  margin-top: 10px;
  width: 687px;
  border: 2px solid rgb(209, 206, 206);
  background-color: rgb(245, 245, 245);
  height: 186px;
  display: flex;
  justify-content: center;
  align-content: center;
  overflow: hidden;
}

.swiper-button-next::after {
  font-family: swiper-icons;
  font-size: var(--swiper-navigation-size);
  text-transform: none !important;
  letter-spacing: 0;
  text-transform: none;
  font-variant: initial;
  line-height: 1;
}

.swiper {
  width: 645px;
  height: 150px;
  overflow: hidden;
  margin: auto 0;
}

.swiper-slide {
  text-align: center;
  font-size: 18px;
  background: #fff;
  height: 150px;
  justify-content: flex-start;
  flex-direction: column;
  /* Center slide text vertically */
  display: -webkit-box;
  display: -ms-flexbox;
  display: -webkit-flex;
  display: flex;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  -webkit-justify-content: center;
  -webkit-box-align: center;
  -ms-flex-align: center;
  -webkit-align-items: center;
  align-items: flex-start;
  a {
    color: #000;
    font-size: 12px;
  }
}

.swiper-slide img {
  display: block;
  width: 100px;
  height: 100px;
  object-fit: cover;
}
//  width: 689px;
</style>
